package pack9999;

import java.util.Arrays;
import java.util.Scanner;

public class DemoA {
    //添加数组
    public static void a() {
        int[] arr = {1, 2, 3, 4, 5};
        int num = 6;
        int[] arr1 = new int[arr.length + 1];
        System.arraycopy(arr, 0, arr1, 0, arr.length);
        arr1[5] = num;
        arr = arr1;
        System.out.println(Arrays.toString(arr));
    }

    //插入数组
    public static void b() {
        int[] arr = {1, 2, 3, 4, 5};
        int num = 6;
        int[] arr1 = new int[arr.length + 1];
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入要插入的位置:");
        int indept = scan.nextInt();
        if (indept > arr.length) {
            System.out.println("错误，没有这个位置。");
            return;
        }
        System.arraycopy(arr, 0, arr1, 0, indept);
        arr1[indept] = num;
        System.arraycopy(arr, indept, arr1, indept + 1, arr.length - indept);
        arr = arr1;
        System.out.println(Arrays.toString(arr));
    }

    /*
    将一个给定的整型数组转置输出，
    例如：源数组，1 2 3 4 5 6
    转置之后的数组，
    6 5 4 3 2 1
     */
    public static void c() {
    int[] len=new int[10];
        for (int i = 0; i < len.length; i++) {
            len[i]=(int) (Math.random()*100+1);
        }
        System.out.println(Arrays.toString(len));

    }

    public static void d(){}

    public static void main(String[] args) {
      c();
    }
}
